Skip to main content
ik_llama.cpp uses the CPU as its base compute device. “Offloading” means sending specific tensors and operations to the GPU for processing. Because GPUs have faster memory bandwidth and parallel compute compared to CPU+RAM, the goal is to offload as much as possible to maximize tokens/second.
For MoE models (DeepSeek, Qwen3-MoE, etc.), always pass a number larger than the model’s actual layer count with -ngl. Use -ngl 999 as a safe catch-all — the runtime caps it at the actual layer count automatically.

Core offload parameters

-ngl / —gpu-layers

Offload the first N transformer layers to VRAM. Pass 999 to offload everything:
To find the exact layer count, open the GGUF file on HuggingFace and scroll to the Tensors table, or run:

-ot / —override-tensor

Override where individual tensors are stored using regular expressions. This is the most powerful offload control available, particularly useful for MoE models where you want experts in RAM and everything else in VRAM.
The pattern before = is a regex matched against tensor names. The value after = is the target device (CPU, CUDA0, CUDA1, etc.).
Tensor names follow the pattern blk.N.tensor_name. Run gguf_dump.py on your model to list all tensor names and identify the right regex pattern.

—fit / —fit-margin

Automatically load as many tensors as available VRAM permits, without specifying an explicit layer count.

Multi-GPU configuration

For a single GPU, use -ngl 999 to fully offload, or a lower number for partial offload:
Use -mg to select which GPU to use when multiple are present but you only want one:

MoE-specific offload options

For Mixture-of-Experts models, ik_llama.cpp provides dedicated parameters to control where expert weights live:

Per-operation offload control

-op / --offload-policy gives fine-grained control over which GGML operations run on GPU:

CUDA fine-tuning

-cuda / --cuda-params accepts a comma-separated list of CUDA-specific tuning options, including fusion control, GPU offload threshold, and MMQ-ID threshold:
The FP16 precision offset for Flash Attention at long contexts:

Practical examples